package MMSD;
import java.util.Scanner;
import java.io.*;
public class Main {
    public static void main(String[] args)throws IOException {
        File file =new File("D:\\长恨歌\\长恨歌未修复版.txt");
        FileReader fr=new FileReader(file);
        BufferedReader br=new BufferedReader(fr);
        String chg=br.readLine();
        br.close();
        fr.close();
        int i,j,a,b;
        System.out.print("统计相关个数，输入字词:");
        Scanner input0= new Scanner(System.in);
        String c0 = input0.next();
        i=chg.length();
        j=i/7;
        File file1=new File("D:\\长恨歌\\长恨歌修复版.txt");
        file1.createNewFile();
        FileWriter writer = new FileWriter(file1);
        for(i=0;i<j-1;i++) {
            if (i % 2 == 0) {
                System.out.print(chg.substring(0+i*7, 7+i*7) + "，");
                writer.write(chg.substring(0+i*7, 7+i*7)+"，");
            }
            if (i % 2 == 1) {
                System.out.println(chg.substring(0+i*7, 7+i*7) + "。");
                writer.write(chg.substring(0+i*7, 7+i*7)+"。"+"\n");
            }
        }
        System.out.println(chg.substring(0+(j-1)*7,7+(j-1)*7));
        writer.write(chg.substring(0+(j-1)*7,7+(j-1)*7)+"\n");
        writer.flush();
        writer.close();
        a=-1;
        b=0;
        while(1==1) {
            chg = chg.substring(a+1);
            a = chg.indexOf(c0);
            if (a >= 0) {
                b = b + 1;
            }
            if (a < 0) {
                System.out.println("所输入的字符，统计的个数为:");
                System.out.println(b);
                break;
            }
        }
    }
}
